#include <stdint.h>
#include "ops.h"

//电脑上测试，用宏定义去掉__code
//CMake需要添加 add_definitions(-DPCTEST)
#ifdef PCTEST
#define __code
#endif

typedef struct{
    uint16_t Kp;
    uint16_t Ki;
    uint16_t Kd;
    uint16_t alpha;
    uint8_t (*func)(uint16_t);  //参数为被控量，返回非0表示没有正确设置，积分值不变
}PID_Param;

typedef struct{
    int16_t inte;
    int16_t err_;
    int16_t dea;  //delta error alpha
}PID_State;

uint8_t PID_apply(__code PID_Param* p, PID_State* s, int16_t err);
